import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

/* Layout */
import Layout from '../views/layout/Layout';

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
    {
        path: '/login',
        component: () => import('@/views/login/index'),
        hidden: true
    },
    { path: '/404', component: () => import('@/views/404'), hidden: true },
    {
        path: '',
        component: Layout,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('@/views/home/index'),
                meta: { title: '首页', icon: 'home' }
            }
        ]
    }
];

export const asyncRouterMap = [
    {
        path: '/goods',
        component: Layout,
        redirect: '/goods/product',
        name: 'goods',
        meta: { title: '商品', icon: 'product' },
        children: [
            {
                path: 'productList',
                name: 'productList',
                component: () => import('@/views/goods/productList/index'),
                meta: { title: '商品列表', icon: 'product-list' }
            },
            {
                path: 'add',
                name: 'add',
                component: () => import('@/views/goods/productList/addProductInfo'),
                meta: { title: '新增商品', icon: 'product-add' },
                hidden: true
            },
            {
                path: 'updateProduct/:id',
                name: 'updateProduct',
                component: () => import('@/views/goods/productList/addProductInfo'),
                meta: { title: '修改商品信息', icon: 'product-update' },
                hidden: true
            },
            {
                path: 'salesActivity',
                name: 'salesActivity',
                component: () => import('@/views/goods/salesActivity/index'),
                meta: { title: '销售活动', icon: 'product-cate' }
            },
            {
                path: 'addActivity',
                name: 'addActivity',
                component: () => import('@/views/goods/salesActivity/add'),
                meta: { title: '发布销售活动', icon: 'product-cate' },
                hidden: true
            },
            {
                path: 'category',
                name: 'category',
                component: () => import('@/views/goods/category/index'),
                meta: { title: '商品分类', icon: 'product-cate' }
            },
            {
                path: 'addCategory',
                name: 'addCategory',
                component: () => import('@/views/goods/category/add'),
                meta: { title: '新增商品分类', icon: 'product-add' },
                hidden: true
            },
            {
                path: 'updateCategory/:id',
                name: 'updateCategory',
                component: () => import('@/views/goods/category/update'),
                meta: { title: '修改商品分类', icon: 'product-add' },
                hidden: true
            },
            {
                path: 'supplementaryInfo',
                name: 'supplementaryInfo',
                component: () => import('@/views/goods/supplementaryInfo/index'),
                meta: { title: '辅助信息', icon: 'product-cate' }
            }
        ]
    },
    {
        path: '/captain',
        component: Layout,
        redirect: '/captain/info',
        name: 'captain',
        meta: { title: '团长', icon: 'user' },
        children: [
            {
                path: 'info',
                name: 'info',
                component: () => import('@/views/captain/info/index'),
                meta: { title: '团长信息', icon: 'product-list' }
            },
            {
                path: 'money',
                name: 'money',
                component: () => import('@/views/captain/money/index'),
                meta: { title: '团长资金', icon: 'product-cate' }
            },
            {
                path: 'withdraw',
                name: 'withdraw',
                component: () => import('@/views/captain/withdraw/index'),
                meta: { title: '团长提现', icon: 'product-cate' }
            },
            {
                path: 'withdrawDeal/:id',
                name: 'withdrawDeal',
                component: () => import('@/views/captain/withdraw/deal'),
                meta: { title: '团长提现处理', icon: 'product-cate' },
                hidden: true
            },
            {
                path: 'recruitRule',
                name: 'recruitRule',
                component: () => import('@/views/captain/recruitRule/index'),
                meta: { title: '招募策略', icon: 'product-cate' }
            },
            {
                path: 'inspireRule',
                name: 'inspireRule',
                component: () => import('@/views/captain/inspireRule/index'),
                meta: { title: '激励策略', icon: 'product-cate' }
            }
        ]
    },
    {
        path: '/vip',
        component: Layout,
        redirect: '/vip/manage',
        name: 'vip',
        meta: { title: '会员', icon: 'user' },
        children: [
            {
                path: 'manage',
                name: 'manage',
                component: () => import('@/views/vip/index'),
                meta: { title: '会员管理', icon: 'product-list' }
            }
        ]
    },
    {
        path: '/supplier',
        component: Layout,
        redirect: '/supplier/info',
        name: 'supplier',
        meta: { title: '供应商', icon: 'user' },
        children: [
            {
                path: 'info',
                name: 'info',
                component: () => import('@/views/supplier/index'),
                meta: { title: '供应商信息', icon: 'product-list' }
            },
            {
                path: 'add',
                name: 'add',
                component: () => import('@/views/supplier/addSupplier'),
                hidden: true,
                meta: { title: '新增供应商', icon: 'product-list' }
            },
            {
                path: 'update/:id',
                name: 'update',
                hidden: true,
                component: () => import('@/views/supplier/addSupplier'),
                meta: { title: '修改供应商信息', icon: 'product-list' }
            },
            {
                path: 'settlement',
                name: 'settlement',
                component: () => import('@/views/supplier/supplierSettlement'),
                meta: { title: '供应商结算', icon: 'product-list' }
            }
        ]
    },
    {
        path: '/storage',
        component: Layout,
        redirect: '/storage/storageIn',
        name: 'storage',
        meta: { title: '仓库', icon: 'user' },
        children: [
            {
                path: 'storageIn',
                name: 'storageIn',
                component: () => import('@/views/storage/storageIn/index'),
                meta: { title: '入库管理', icon: 'product-list' }
            },
            {
                path: 'addStorageIn',
                name: 'addStorageIn',
                component: () => import('@/views/storage/storageIn/add'),
                meta: { title: '新增入库', icon: 'product-list' },
                hidden: true
            },
            {
                path: 'storageOut',
                name: 'storageOut',
                component: () => import('@/views/storage/storageOut/index'),
                meta: { title: '出库管理', icon: 'product-list' }
            },
            {
                path: 'addStorageOutOther',
                name: 'addStorageOutOther',
                component: () => import('@/views/storage/storageOut/addOther'),
                meta: { title: '其他出库', icon: 'product-list' },
                hidden: true
            },
            {
                path: 'addStorageSales',
                name: 'addStorageSales',
                component: () => import('@/views/storage/storageOut/addSales'),
                meta: { title: '发货出库', icon: 'product-list' },
                hidden: true
            },

            {
                path: 'check',
                name: 'check',
                component: () => import('@/views/storage/check/index'),
                meta: { title: '库存盘点', icon: 'product-list' }
            },
            {
                path: 'addCheck',
                name: 'addCheck',
                component: () => import('@/views/storage/check/add'),
                meta: { title: '新增盘点', icon: 'product-list' },
                hidden: true
            },
            {
                path: 'storageCurrent',
                name: 'storageCurrent',
                component: () => import('@/views/storage/storageCurrent/index'),
                meta: { title: '现有库存', icon: 'product-list' }
            }
        ]
    },
    {
        path: '/global',
        component: Layout,
        redirect: '/global/index',
        name: 'global',
        meta: { title: '会员', icon: 'user' },
        children: [
            {
                path: 'index',
                name: 'index',
                component: () => import('@/views/global/index'),
                meta: { title: '全局设置', icon: 'order-setting' }
            }
        ]
    },
    {
        path: '/order',
        component: Layout,
        redirect: '/order/index',
        name: 'order',
        meta: { title: '订单', icon: 'user' },
        children: [
            {
                path: 'index',
                name: 'orderindex',
                component: () => import('@/views/order/index'),
                meta: { title: '订单管理', icon: 'product-list' }
            },
            {
                path: 'detail/:id',
                name: 'orderdetail',
                component: () => import('@/views/order/detail'),
                hidden: true,
                meta: { title: '订单详情', icon: 'product-list' }
            }
        ]
    },
    {
        path: '/datas',
        component: Layout,
        redirect: '/datas/index',
        name: 'datas',
        meta: { title: '销售报表', icon: 'user' },
        children: [
            {
                path: 'salesData',
                name: 'salesData',
                component: () => import('@/views/datas/salesData/index'),
                meta: { title: '销售数据', icon: 'product-list' }
            },
            {
                path: 'goodsData',
                name: 'goodsData',
                component: () => import('@/views/datas/goodsData/index'),
                meta: { title: '商品数据', icon: 'product-list' }
            },
            {
                path: 'comOperation',
                name: 'comOperation',
                component: () => import('@/views/datas/comOperation/index'),
                meta: { title: '社区店运营', icon: 'product-list' }
            },
            {
                path: 'storeOperation',
                name: 'storeOperation',
                component: () => import('@/views/datas/storeOperation/index'),
                meta: { title: '店铺运营', icon: 'product-list' }
            }
        ]
    },
    {
        path: '/profile',
        component: Layout,
        redirect: '/profile/index',
        name: 'profile',
        meta: { title: '修改密码', icon: 'user' },
        children: [
            {
                path: 'index',
                name: 'pass',
                component: () => import('@/views/profile/index'),
                meta: { title: '订单管理', icon: 'product-list' }
            }
        ],
        hidden: true
    },
    { path: '*', redirect: '/404', hidden: true }
];

export default new Router({
    // mode: 'history', //后端支持可开
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRouterMap
});
